#include "stm32f10x.h"                  // Device header
#include "Delay.h"
#include "OLED.h"
#include "Encoder.h"
#include "Motor.h"

int16_t speed = 0;

int main(void)
{
	OLED_Init();
	Encoder_Init();
	Motor_Init();
	OLED_ShowString(1, 1, "Speed:000%:");
	while (1)
	{
		speed = Encoder_SpeedGet();
		if (speed < -100)
		{
			speed = -100;
			TIM_SetCounter(TIM3, 65136);
		}
		if (speed > 100)
		{
			speed = 100;
			TIM_SetCounter(TIM3, 400);
		}	
		OLED_ShowSignedNum(1, 7, speed, 3);
		Motor_SpeedControl(speed);
	}
}



